package com.jiazixuan.stock;

import com.google.common.collect.Lists;
import com.jiazixuan.stock.mapper.StockBusinessMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;
import java.util.stream.Collectors;

@SpringBootTest
public class testMapper {

    @Autowired
    private StockBusinessMapper stockBusinessMapper;

    @Test
    public void test01(){
        //从数据库查询A股编号
        List<String> allCodes = stockBusinessMapper.getStockIds();
        //System.out.println(allCodes);
        //给编号加上前缀
        allCodes = allCodes.stream().map(code->code.startsWith("6")?"sh"+code:"sz"+code).collect(Collectors.toList());
        //System.out.println(allCodes);
        //将整个大集合分割成小集合
        Lists.partition(allCodes,15).forEach(codes->{
            System.out.println("size:"+codes.size()+":"+codes);
        });
    }
}
